package com.d3works.apps.account.web;

import com.d3works.apps.account.db.AccountConfig;
import com.d3works.apps.account.service.analytic.AnalyticAxisByCompanyService;
import com.d3works.exception.service.TraceBackService;
import com.d3works.inject.Beans;
import com.d3works.rpc.ActionRequest;
import com.d3works.rpc.ActionResponse;

public class AnalyticAxisByCompanyController {

  public void setAxisDomain(ActionRequest request, ActionResponse response) {
    try {
      AccountConfig accountConfig = request.getContext().getParent().asType(AccountConfig.class);
      if (accountConfig != null) {
        String domain = Beans.get(AnalyticAxisByCompanyService.class).getAxisDomain(accountConfig);
        if (domain != null) {
          response.setAttr("analyticAxis", "domain", domain);
        }
      }
    } catch (Exception e) {
      TraceBackService.trace(response, e);
    }
  }
}
